import { BasePagesResponseData, BaseResponseData } from "@renderer/interface/baseData";
import { ClassItem } from "@renderer/interface/class";
import { Customer, DateRange, FollowPageItem, Funnel, RecruitForm, RecruitItem, SearchRecruit, Transaction } from "@renderer/interface/recruit";
import http from "@renderer/utils/request";

/**
 * 新建客户
 * @param form 客户表单
 * @returns 
 */
export const postConsultAddApi = (form: RecruitForm) =>
	http.post<BaseResponseData<null>>('/crm/recruit/consult/add', form)

/**
 * 获取客户列表
 * @param data 查询客户表单
 * @returns 
 */
export const getConsultPageApi = (data: SearchRecruit) =>
	http.get<BasePagesResponseData<RecruitItem>>('/crm/recruit/consult/page', data)

/**
 * 获取我的成交额
 * @param form 时间范围
 * @returns 
 */
export const getStatisticTransactionApi = (form: DateRange) =>
	http.get<BaseResponseData<Transaction>>('/crm/recruit/channel/statistic/transaction', form)

/**
 * 获取漏斗图数据
 * @param form 时间范围
 * @returns 
 */
export const getStatisticFunnelApi = (form: DateRange) =>
	http.get<BaseResponseData<Funnel[]>>('/crm/recruit/channel/statistic/funnel', form)

/**
 * 获取全部客户
 * @param form 搜索客户表单
 * @returns 
 */
export const getConsultAllApi = (form: SearchRecruit) =>
	http.get<BasePagesResponseData<RecruitItem>>('crm/recruit/consult/all', form)

/**
 * 获取公有池客户
 * @param form 搜索客户表单
 * @returns 
 */
export const getPoolPageApi = (form: SearchRecruit) =>
	http.get<BasePagesResponseData<RecruitItem>>('/crm/recruit/pool/page', form)

/**
 * 领取客户（单条）
 * @param id 客户id
 * @returns 
 */
export const getPoolReceiveApi = (id: string) =>
	http.get<BaseResponseData<null>>(`/crm/recruit/pool/receive/${id}`)

/**
 * 领取客户（多条）
 * @param arr 客户id数组
 * @returns 
 */
export const postPoolReceiveBatchApi = (arr: string[]) =>
	http.post<BaseResponseData<null>>('/crm/recruit/pool/receiveBatch', arr)

/**
 * 查询客户详情
 * @param id 客户id
 * @returns 
 */
export const getConsultDetailApi = (id: string) =>
	http.get<BaseResponseData<RecruitItem>>(`/crm/recruit/consult/detail/${id}`)

/**
 * 获取客户分页列表
 * @param form 查询课程列表
 * @returns 
 */
export const getCoursePageApi = (form: { current: number, size: number, customerId: string }) =>
	http.get<BasePagesResponseData<ClassItem>>('/crm/recruit/consult/course/page', form)

/**
 * 导入客户
 * @param data 客户Excel表
 * @returns 
 */
export const postConsultImport = (data: FormData) =>
	http.post<BaseResponseData<null>>('/crm/recruit/consult/import', data)

/**
 * 导出客户
 * @returns 
 */
export const postConsultExport = () =>
	http.post<BaseResponseData<null>>('/crm/recruit/consult/export')

/**
 * 修改客户
 * @param form 客户信息表单
 * @returns 
 */
export const postConsultUpdateApi = (form: Customer) =>
	http.post<BaseResponseData<null>>('/crm/recruit/consult/update', form)

/**
 * 获取跟进列表
 * @param form 
 * @returns 
 */
export const getFollowPageApi = (form: { current: number, size: number, customerId: string }) =>
	http.get<BasePagesResponseData<FollowPageItem>>('/crm/recruit/consult/follow/page', form)